@extends("la.layouts.app")

@section("contentheader_title")
    <a href="{{ url(config('laraadmin.adminRoute') . '/wechat-upload') }}">微信资源管理</a> :
@endsection
@section("contentheader_description", '微信资源管理')
@section("section", "微信资源管理")
@section("section_url", url(config('laraadmin.adminRoute') . '/wechat-upload'))
@section("sub_section", "Edit")

@section("htmlheader_title", "编辑微信资源")

@section("main-content")

    @if (count($errors) > 0)
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <div class="box">
        <div class="box-header">

        </div>
        <div class="box-body">
            <div class="row">
                <div class="col-md-8 col-md-offset-2">
                    <form method="POST" action="/admin/wechat-upload/{{ $wechatUpload->id }}" accept-charset="UTF-8" id="organization-edit-form" novalidate="novalidate">
                        <input name="_method" type="hidden" value="PUT">
                        <input name="id" type="hidden" value="{{ $wechatUpload->id }}" />
                        {!! csrf_field() !!}
                        <div class="form-group">
                            <label for="name">源文件 :</label>
                            <a href="{{ $wechatUpload->url }}" target="_blank">
                                <input class="form-control" disabled="" value="{{ $wechatUpload->url }}"/>
                            </a>
                        </div>
                        <div class="form-group">
                            <label for="name">标题 :</label>
                            <input class="form-control" name="title" value="{{ $wechatUpload->title }}"/>
                        </div>
                        <div class="form-group">
                            <label for="name">时长 :</label>
                            <input class="form-control" value="{{ $wechatUpload->duration_word }}" disabled/>
                        </div>
                        <div class="form-group">
                            <label for="name">最小价格 :</label>
                            <input class="form-control" name="min_price" value="{{ $wechatUpload->min_price }}"/>
                        </div>
                        <div class="form-group">
                            <label for="name">最大价格 :</label>
                            <input class="form-control" name="max_price" value="{{ $wechatUpload->max_price }}"/>
                        </div>
                        <div class="form-group">
                            <label for="name">上传者 :</label>
                            <input class="form-control" value="{{ $wechatUpload->openid }}" disabled/>
                        </div>
                        <div class="form-group">
                            <label for="name">状态 :</label>
                            <select name="status" class="form-control">
                                <option value="0" {{ 0 == $wechatUpload->status ? 'selected' : '' }}>正常</option>
                                <option value="1" {{ 1 == $wechatUpload->status ? 'selected' : '' }}>隐藏</option>
                                <option value="2" {{ 2 == $wechatUpload->status ? 'selected' : '' }} disabled>命名中</option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="name">类型 :</label>
                            <input class="form-control" value="{{ $wechatUpload->type_word }}" disabled/>
                        </div>
                        <div class="form-group">
                            <label for="name">打赏次数 :</label>
                            <input class="form-control" value="{{ $wechatUpload->buy_count }}" disabled/>
                        </div>
                        <div class="form-group">
                            <label for="name">打赏总额 :</label>
                            <input class="form-control" value="{{ $wechatUpload->total_price }}" disabled/>
                        </div>
                        <div class="form-group">
                            <label for="name">推广链接 :</label>
                            <input class="form-control" value="{{ $wechatUpload->promotion_url }}" readonly/>
                        </div><div class="form-group">
                            <label for="name">文件大小 :</label>
                            <input class="form-control" value="{{ byte_format($wechatUpload->byte) }}" readonly/>
                        </div>
                        <div class="form-group">
                            <label for="name">推广链接二维码 :</label>
                            <div style="width: 256px;height: 256px;" id="qr-img"></div>
                        </div>
                        <div class="form-group">
                            <input class="btn btn-success" type="submit" value="修改">
                            <button type="button" class="btn btn-default pull-right">
                                <a href="/admin/wechat-upload">返回</a>
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

@endsection

@push('scripts')
    <script src="/js/lib/qrcodejs/qrcode.js"></script>
    <script src="/js/jquery-1.3.2.min.js"></script>
    <script src="/js/jquery.imgbox.pack.js"></script>
    <script>
        new QRCode(document.getElementById('qr-img'), '{{ $wechatUpload->promotion_url }}');
    </script>
@endpush
